package com.cetcs.kmga.dataManager.entity.logManager.vi;

import com.cetcs.kmga.dataManager.util.MD5;
import org.apache.commons.lang.StringUtils;

import java.util.Arrays;
import java.util.List;
import java.util.stream.Collectors;

/**
 * 日志搜索 -- 普通搜索
 *
 * @author yyangs
 * @version V1.0 创建时间：2017-08-30 14:30
 *          Copyright 2017 by CETC
 */
public class LogSearchTopVi {

    private String dateRange;


    private List<LogIndexSearch> keyWords;

    public List<LogIndexSearch> getKeyWords() {
        return keyWords;
    }

    public void setKeyWords(List<LogIndexSearch> keyWords) {
        this.keyWords = keyWords;
    }

    public String getDateRange() {
        return dateRange;
    }

    public void setDateRange(String dateRange) {
        this.dateRange = dateRange;
    }


    @Override
    public String toString() {
        String str = "LogSearchTopVi{" +
                "dateRange='" + dateRange + '\'' +
                '}';
        String keywordStr = "";
        if (this.keyWords != null && this.keyWords.size( ) > 0) {
            List<String> keyArr = this.keyWords.stream( ).map(p -> p.getValue( )).filter(p -> StringUtils.isNotBlank(p)).collect(Collectors.toList( ));
            if (keyArr != null && keyArr.size( ) > 0) {
                keywordStr = String.join(",", keyArr);
            }
        }
        String retStr = str + keywordStr;
        MD5 md5 = new MD5( );
        String md5Str = md5.getMD5ofStr(retStr);
        return md5Str;
    }


}
